#include "OgreStableHeaders.h"
#include "OgreExDispatcher.h"
#include "OgreExAsynPort.h"
namespace OgreEx
{

	Dispatcher::Dispatcher() : mPortMap(),mDefaultPort(NULL)
	{
		init();
	}

	Dispatcher::~Dispatcher()
	{
		release();
	}

	void Dispatcher::init()
	{
		mDefaultPort = new AsynPort();
	}

	void Dispatcher::release()
	{
		PortMap::iterator iter = mPortMap.begin();
		PortMap::iterator iterend = mPortMap.end();

		for( ; iter != iterend ; ++iter )
		{
			delete (*iter).second;
		}
		mPortMap.clear();

		if( mDefaultPort )
		{
			delete mDefaultPort;
			mDefaultPort = NULL;
		}

	}

}